package hot100;

public class Solution238 {
    public int[] productExceptSelf(int[] nums) {
        int[] res = new int[nums.length];
        int tmp = 1;
        for (int i = 0; i < nums.length; i++) {
            res[i] = tmp;
            tmp *= nums[i];
        }
        tmp = nums[nums.length - 1];
        for (int i = nums.length - 2; i >= 0; i--) {
            res[i] *= tmp;
            tmp *= nums[i];
        }
        return res;
    }
}
